<style>
    .artifactDetails .popover {
        max-width: 400px !important;
    }

    .ace_editor {
        height: 700px;
    }
</style>
<div class="modal-header">
    <h3 class="modal-title">
        <b style="color: #286090">持续集成-Android加固</b>
    </h3>
</div>
<div class="modal-body">

    <form class="bs-example form-horizontal">

        <div class="wrapper-md">
            <!-- toaster directive -->
            <toaster-container
                    toaster-options="{'position-class': 'toast-top-right', 'close-button':true}"></toaster-container>
            <uib-tabset>
                <uib-tab index="0" heading="执行加固">
                    <div style="font-size:1em;">&nbsp;</div>
                    <div class="form-group">
                        <div class="col-md-6">
                            <label class="col-lg-4 control-label"><span style="color: #ec2121;">*</span>任务名称
                            </label>
                            <div class="col-lg-8">
                                <input type="text" class="form-control" placeholder="JenkinsJob名称" readonly
                                       ng-model="jobItem.deployJobName">
                            </div>
                        </div>
                    </div>


                    <div class="form-group">
                        <div class="col-md-6">
                            <label class="col-lg-4 control-label">构建渠道</label>
                            <div class="col-lg-8">
                                <!--required-->
                                <select class="form-control" ng-model="nowChannelType.selected"
                                        ng-options="ct.code as ct.name for ct in channelType">
                                    <option value="">--请选择--</option>
                                </select>
                            </div>
                        </div>
                    </div>

                    <div class="form-group" ng-show="nowChannelType.selected == 1">
                        <!--多选渠道-->
                        <div class="col-md-12">
                            <label class="col-lg-2 control-label"><span style="color: #ec2121;">*</span>选择渠道</label>
                            <div class="col-lg-10">
                                <ui-select multiple class="form-control" ng-model="channelGroup.selected"
                                           theme="bootstrap" sortable="true" close-on-select="false">
                                    <ui-select-match placeholder="多选渠道名称......">{{$item.code + " - " + $item.name}}
                                    </ui-select-match>
                                    <ui-select-choices refresh-dalay="0"
                                                       repeat="item in channelGroupList | filter: $select.search">
                                        <div ng-bind-html="item.groupCode | highlight: $select.search"></div>
                                        <small>{{item.code + " - " + item.name}}</small>
                                    </ui-select-choices>
                                </ui-select>
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-md-6">
                            <label class="col-lg-4 control-label"><span style="color: #ec2121;">*</span>构件名称</label>
                            <div class="col-lg-8">
                                <ui-select ng-model="nowArtifact.selected" theme="bootstrap">
                                    <ui-select-match placeholder="搜索构件编号......">{{$select.selected.versionName}}
                                    </ui-select-match>
                                    <ui-select-choices refresh="queryArtifact($select.search)" refresh-dalay="0"
                                                       repeat="item in buildArtifactList | filter: $select.search">
                                        <div ng-bind-html="item.versionName | highlight: $select.search"></div>
                                    </ui-select-choices>
                                </ui-select>
                            </div>
                        </div>
                    </div>


                    <div class="form-group artifactDetails" ng-show="nowArtifact.selected != null">
                        <div ng-include="'tpl/modal/ci/include/artifact_details.html'"></div>
                    </div>

                    <div class="form-group">
                        <div style="text-align:center;">
                            <div style="text-align:center;">
                                <button class="btn btn-xs"
                                        style="margin-right: 5px; background-color: #ff5f87; color: white;"
                                        ng-click="deployJob()">
                                    <span class="fa fa-android"></span>加固
                                </button>
                            </div>
                        </div>
                    </div>
                </uib-tab>
                <uib-tab index="1" heading="构建参数" ng-show="jobItem.id != 0">
                    <div style="font-size:1em;">&nbsp;</div>
                    <div ui-ace="aceOption" ng-readonly=true ng-model="jobItem.paramsYaml" class="ace_editor"></div>
                </uib-tab>
                <uib-tab index="2" heading="历史任务">
                    <div style="font-size:1em;">&nbsp;</div>
                    <div class="panel-body">
                        <div>
                            <table class="table table-hover table-bordered table-striped">
                                <thead>
                                <tr>
                                    <td class="col-md-1">编号</td>
                                    <td class="col-md-10">任务详情</td>
                                    <td class="col-md-1">操作</td>
                                </tr>
                                </thead>
                                <tbody>
                                <tr ng-repeat="item in pageData">
                                    <td>
                                        <b style="color: #c9302c" ng-if="item.buildNumber ==-1">队列</b>
                                        <b style="color: #286090" ng-if="item.buildNumber > 0">{{item.buildNumber}}</b>
                                    </td>
                                    <td>
                                        <!--构建细节-->
                                        <div ng-include="'tpl/modal/ci/include/build_details.html'"></div>
                                    </td>
                                    <td>
                                        <button ng-click="rebuildJob(item.id)"
                                                class="btn btn-xs"
                                                ng-disabled="butSaveDisabled"
                                                style="background-color: #ff8700; color: white;">
                                            <i class="fa fa-spin fa-spinner" ng-show="butBuildSpinDisabled"></i>
                                            <i class="icon icon-control-play" ng-show="!butBuildSpinDisabled"></i>执行
                                        </button>
                                        <!--margin-left: 5px;-->
                                        </br>
                                        <a class="btn btn-xs"
                                           style="margin-top:5px; background-color: #737373; color: white;"
                                           href="{{item.console}}"
                                           target="_blank"><i class="fa fa-terminal"></i>日志</a>
                                        </br>
                                        <a class="btn btn-xs"
                                           ng-show="item.buildPhase == 'FINALIZED' && item.buildStatus == 'SUCCESS'"
                                           style="margin-top:5px; background-color: #8ec165; color: white;"
                                           href="#/access/androidArtifact?buildId={{item.id}}"
                                           target="_blank"><i class="fa fa-android"></i>下载</a>
                                    </td>
                                </tr>
                                </tbody>
                                <tfoot>
                                <tr>
                                    <td colspan="4">
                                        <ul style="margin: 0px; float: right;" uib-pagination total-items="totalItems"
                                            ng-model="currentPage" items-per-page="pageLength" max-size="10"
                                            ng-change="pageChanged(currentPage)" previous-text="&lsaquo;"
                                            next-text="&rsaquo;"></ul>
                                    </td>
                                </tr>
                                </tfoot>
                            </table>
                        </div>
                    </div>
                </uib-tab>
            </uib-tabset>
        </div>

    </form>

    <div ng-if="alert.type != ''">
        <div uib-alert ng-class="'alert-' + alert.type" close="closeAlert()">{{alert.msg}}</div>
    </div>
</div>